<?php
/**
 * wap 2.0 用户中心－订单详情
 */


$pic_format = array('w_h'=>'111x140', 'ratio'=>70);
$isHD && $pic_format = array('w_h'=>'222x280', 'ratio'=>80);

$order_sn = isset($_GET['order_sn']) ? trim($_GET['order_sn']) : 0;

/* 订单详情 */
//$order = $mInterface->getUserOrderDetail($user_token, $order_sn);


if (!is_array($order) || empty($order) )
{
	//show_message('订单不存在', '返回订单列表', 'index.php?m=user&act=order&step=list', 'error');
}


foreach ($order['products'] AS $key => $val)
{
	$productInfo = get_product_info($val['product_id']);
	$order['products'][$key]['small_image'] = get_small_image($productInfo['small_image'], $pic_format);
	$order['products'][$key]['size_id'] = $returnGoodSizes[$val['product_id']];

	if (in_array($val['brand_id'], $beauty_brands)){
		$order['products'][$key]['in_beauty'] = 1;
	}

	// 商品数量、金额小计
	$order['products'][$key]['subtotal'] = $val['num'] * $val['sexmall_price'];
	$order['product_count'] += $val['num'];
	$order['product_amount'] += $val['num'] * $val['sexmall_price'];
}

// 下单1小时内订单显示为 “待审核订单”
$now = local_time();
if ($now - $order['add_time'] < 3600 && $order['order_status'] == 10 && $order['pay_type'] != 8){
	$order['order_status'] = 1;
	$order['order_status_name'] = '已支付，待审核订单';
}
else if ($now - $order['add_time'] < 3600 && $order['order_status'] == 10)
{
	$order['order_status'] = 1;
	$order['order_status_name'] = '待审核订单';
}
else if ($order['order_status'] == 97){
	$order['order_status_name'] = '订单已取消';
}

/* 支付方式 */
//$payment = get_payment_list(1, '', 0, 0, $order['pay_type']);

if ($order['pay_type'] == 10){
	$order['pay_type_name'] = '钱包支付';
}else{
	if ($order['pay_type'] == 8){
		$order['pay_type_name'] = '货到付款';
	}else{
		$order['pay_type_name'] = '在线支付';
	}
	if ($order['surplus'] > 0){
		$order['pay_type_name'] .= ' + 钱包支付';
	}
}

$order['add_time'] = date('Y-m-d H:i:s', $order['add_time']);
$order['money'] = ($order['money']);
$order['carriage'] = ($order['carriage']);
$order['favourable_money'] = ($order['favourable_money']);

wap_setcookie("WAP[back_act]", 'index.php?' . http_build_query($back_param));


$smarty->assign('order',      $order);


$smarty->display('user_order_detail.dwt');